﻿  <%@ Page ValidateRequest="false" Language="C#" AutoEventWireup="true" CodeBehind="BGMKPIList.aspx.cs" Inherits="KPIS.GERP.GBMS.APP_UI.Form.Bgm_Kpi_List" %>
<%--<%@ Register TagPrefix="telerik" Namespace="Telerik.Reporting" Assembly="Telerik.Reporting, Version=6.2.12.1017, Culture=neutral, PublicKeyToken=a9d7983dfcc261be" %>--%>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>รายการตัวชึ้วัดความสำเร็จ</title>
    <link href="../../Styles/StyleSheet.css" rel="stylesheet" type="text/css" />
    <script src="../../Scripts/DatePicker.js" type="text/javascript"></script>
    <script src="../../Scripts/Common.js" type="text/javascript"></script>
    <script src="../../Scripts/jquery-1.9.0.min.js" type="text/javascript"></script>
    
    <script type="text/javascript">
        function minmax(value, min, max) {
            if (parseInt(value) < 0 || isNaN(value)) {
                alert('กรุณากรอกน้ำหนัก');
            } else if (parseInt(value) > 100) {
                alert('น้ำหนักต้องไม่เกิน 100');
                return 100;
            } else return value;{
              
            }
        }
   </script>
    
</head>
<body>
     <form id="form1" runat="server" style="font-size:small;  margin-top:45px">
        <telerik:RadScriptManager ID="RadScriptManager1" runat="server">
        </telerik:RadScriptManager>
        <telerik:RadAjaxManager ID="RadAjaxManager1" runat="server">
            <AjaxSettings>
                <telerik:AjaxSetting AjaxControlID="PanelCommand">
                    <UpdatedControls>
                        <telerik:AjaxUpdatedControl ControlID="PanelCommand" />
                        <telerik:AjaxUpdatedControl ControlID="pnlLoadGrid" />
                        <telerik:AjaxUpdatedControl ControlID="pnlInfo" />
                        <telerik:AjaxUpdatedControl ControlID="pnlTarget"/>
                        </UpdatedControls>
                </telerik:AjaxSetting>
                <telerik:AjaxSetting AjaxControlID="pnlInfo">
                    <UpdatedControls>
                        <telerik:AjaxUpdatedControl ControlID="PanelCommand" />
                        <telerik:AjaxUpdatedControl ControlID="pnlLoadGrid" />
                        <telerik:AjaxUpdatedControl ControlID="pnlInfo" />
                        <telerik:AjaxUpdatedControl ControlID="pnlTarget" />
                        <telerik:AjaxUpdatedControl ControlID="RadGrid1"/>  
                       </UpdatedControls>
                </telerik:AjaxSetting>
                <telerik:AjaxSetting AjaxControlID="pnlLoadGrid">
                    <UpdatedControls>
                        <telerik:AjaxUpdatedControl ControlID="PanelCommand" />
                        <telerik:AjaxUpdatedControl ControlID="pnlLoadGrid" />
                        <telerik:AjaxUpdatedControl ControlID="pnlInfo" />
                        <telerik:AjaxUpdatedControl ControlID="pnlTarget" />
                        <telerik:AjaxUpdatedControl ControlID="RadGrid1"/>  
                    </UpdatedControls>
                </telerik:AjaxSetting>
            </AjaxSettings>
        </telerik:RadAjaxManager>
        <telerik:RadAjaxLoadingPanel ID="RadAjaxLoadingPanel1" runat="server" BackgroundPosition="None"> 
        </telerik:RadAjaxLoadingPanel>
     
        <asp:Panel runat="server" ID="PanelCommand">
        <div class="DivInfo " style="height: 22px; width:1400px;  position:fixed; top:0; left:0; margin-bottom:0px; ">
            <ul class="treeview-list">
                <li class="treeview-item" style="border: none">
                      <asp:LinkButton Font-Underline="False" Font-Weight="Bold" ID="ShowGrid" 
                          runat="server" onclick="ShowGrid_Click">
                          <img style="border:0px;vertical-align:middle;" alt="" src="../Image/Grid/table.gif" />&nbsp;&nbsp;แสดงข้อมูลทั้งหมด
                      </asp:LinkButton>                        
                 </li> 
                 <li class="treeview-item">
                     <asp:LinkButton Font-Underline="False" Font-Weight="Bold" ID="AddNew" 
                         runat="server" onclick="AddNew_Click">
                         <img style="border:0px;vertical-align:middle;" alt="" src="../Image/Grid/AddRecord.gif" />&nbsp;&nbsp;เพิ่มข้อมูลใหม่
                     </asp:LinkButton>
                 </li>
                 <li class="treeview-item">
                     <asp:LinkButton Font-Underline="False" Font-Weight="Bold" ID="Save_AddNew" 
                         runat="server" onclick="Save_AddNew_Click" OnClientClick="javascript:return confirm('ต้องการบันทึกข้อมูลใช่หรือไม่')">
                        <img style="border:0px;vertical-align:middle;" alt="" src="../Image/Grid/Cmd_Save.gif" />&nbsp;&nbsp;บันทึกข้อมูล
                     </asp:LinkButton>  
                 </li>
                 <li class="treeview-item">
                     <asp:LinkButton Font-Underline="False" Font-Weight="Bold" ID="Save_Edit" 
                         runat="server" onclick="Save_Edit_Click">
                        <img style="border:0px;vertical-align:middle;" alt="" src="../Image/Grid/Cmd_Save.gif" CommandName="GridEdit" />&nbsp;&nbsp;บันทึกข้อมูล
                     </asp:LinkButton>  
                 </li>
                 <li class="treeview-item">
                   <asp:LinkButton ID="Delete" runat="server" CssClass="ControlLinkButton" 
                       OnClientClick="javascript:return confirm('ต้องการลบข้อมูลใช่หรือไม่')" Onclick="Delete_Click">
                            <img style="border:0px;vertical-align:middle;" alt="" src="../Image/Grid/Delete.gif" CommandName="GridDelete" />&nbsp;&nbsp;ลบข้อมูล
                   </asp:LinkButton>
                   <!--<script type="text/javascript">
                       function CheckSomeChecked() {
                        
                            var isCheckedSome = false;
                            var grid = $find('<%=dtgKpiCtrl.ClientID %>');
                            var master = grid.get_masterTableView();
                            var rows = master.get_dataItems();

                            for (var anrow in rows) {
                                var row = rows[anrow];
                                var cell;
                                var checkBox;
                                   
                                cell = master.getCellByColumnUniqueName(row, "checkCol");
                                checkBox = cell.firstChild;

                                if (checkBox.checked)
                                    isCheckedSome = true;
                            }


                           if (!isCheckedSome) {
                               alert("เลือกรายการที่จะลบก่อน");
                               return false;
                           } else
                               confirm('ต้องการลบข้อมูลใช่หรือไม่');
                       }
                   </script> -->
                </li>
                <li class="treeview-item">
                   <asp:LinkButton ID="DeleteEdit" runat="server" CssClass="ControlLinkButton" 
                       OnClientClick="javascript:return confirm('ต้องการลบข้อมูลใช่หรือไม่')" Onclick="DeleteEdit_Click">
                            <img style="border:0px;vertical-align:middle;" alt="" src="../Image/Grid/Delete.gif" CommandName="GridDelete" />&nbsp;&nbsp;ลบข้อมูล
                   </asp:LinkButton>
                </li>
            </ul>
         </div>
        </asp:Panel>
    <div>
       <asp:Panel ID="pnlLoadGrid" runat="server">
       <table width="100%">
            <tr>
                 <td align="left" valign="top" bgcolor="#7DA5E0" style="padding: 5px; color: #FFFFFF; font-weight: bold; 
                     font-family: 'Segoe UI'; font-size: 13px;" class="style2">
                     <asp:Label ID="lblKpiName" runat="server" Visible="True"></asp:Label>
                </td>
            </tr>
            <tr>
                <td>
                    <telerik:RadGrid GroupingSettings-CaseSensitive="false" ID="dtgKpiCtrl" runat="server"
                        AllowFilteringByColumn="true" AllowMultiRowSelection="true" 
                        AllowPaging="true" AllowSorting="true"
                        AutoGenerateColumns="false" PageSize="10" 
                        OnNeedDataSource="dtgKpiCtrl_NeedDataSource" 
                        OnItemCommand="dtgKpiCtrl_ItemCommand" style="margin-bottom: 0px">
            
                    <MasterTableView AllowMultiColumnSorting="true" DataKeyNames="kpi_seq" ClientDataKeyNames="kpi_seq" Width="100%">
                        <PagerStyle Mode="NextPrevAndNumeric" />
                            <Columns>
                                <telerik:GridBoundColumn HeaderText="PK"  UniqueName="kpi_seq" DataField="kpi_seq" Visible="false"></telerik:GridBoundColumn>
                                <telerik:GridBoundColumn UniqueName="kpi_type_seq" DataField="kpi_type_seq" Visible="false"></telerik:GridBoundColumn>
                                <telerik:GridBoundColumn UniqueName="kpi_det_seq" DataField="kpi_det_seq" Visible="false"></telerik:GridBoundColumn>
                                <telerik:GridBoundColumn UniqueName="target_det_seq" DataField="target_det_seq" Visible="false"></telerik:GridBoundColumn>
                                <telerik:GridBoundColumn UniqueName="bgm_kpi_type_seq" DataField="bgm_kpi_type_seq" Visible="false"></telerik:GridBoundColumn> 
                                <telerik:GridBoundColumn UniqueName="strategy_list_seq" DataField="strategy_list_seq" Visible="false"></telerik:GridBoundColumn>
                                <telerik:GridBoundColumn UniqueName="description" DataField="description" Visible="false"></telerik:GridBoundColumn>
                                <telerik:GridBoundColumn UniqueName="weight" DataField="weight" Visible="false"></telerik:GridBoundColumn>
                                <telerik:GridBoundColumn UniqueName="updated_when" DataField="updated_when" Visible="false"></telerik:GridBoundColumn>
                                <telerik:GridBoundColumn UniqueName="target_seq" DataField="target_seq" Visible="false"></telerik:GridBoundColumn>
                                <telerik:GridClientSelectColumn UniqueName="checkCol">
                                        <HeaderStyle Width="20px"/>
                                </telerik:GridClientSelectColumn>
                                <telerik:GridButtonColumn HeaderText="แก้ไข" ImageUrl="../Image/Grid/Edit.gif" ButtonType="ImageButton" CommandName="GridEdit">
                                    <HeaderStyle Width="20px" />
                                </telerik:GridButtonColumn>
                                <telerik:GridBoundColumn HeaderText="ชื่อตัวชี้วัด" DataField="kpi_name" UniqueName="kpi_name"
                                     ShowFilterIcon="false" CurrentFilterFunction="Contains" AutoPostBackOnFilter="true" FilterControlWidth="100%">
                                </telerik:GridBoundColumn>
                                <telerik:GridBoundColumn HeaderText="ประเภทตัวชี้วัด" DataField="bgm_kpi_type_name" UniqueName="bgm_kpi_type_name"
                                    ShowFilterIcon="false" CurrentFilterFunction="Contains" AutoPostBackOnFilter="true" FilterControlWidth="100%">
                                    <HeaderStyle Width="120px" />
                                </telerik:GridBoundColumn>
                                <telerik:GridBoundColumn HeaderText="หน่วยวัด" DataField="kpi_unit" UniqueName="kpi_unit"
                                    ShowFilterIcon="false" CurrentFilterFunction="Contains" AutoPostBackOnFilter="true" FilterControlWidth="100%">
                                <HeaderStyle Width="120px" />
                                </telerik:GridBoundColumn>
                                <telerik:GridBoundColumn HeaderText="ประเภทเป้าหมาย" DataField="target_name" UniqueName="target_name"
                                    ShowFilterIcon="false" CurrentFilterFunction="Contains" AutoPostBackOnFilter="true" FilterControlWidth="100%">
                                    <HeaderStyle Width="120px" />
                              </telerik:GridBoundColumn>
                          </Columns>
                      </MasterTableView>
                       <ClientSettings>
                           <Selecting AllowRowSelect="True">
                               
                           </Selecting>
                       </ClientSettings>     
                    </telerik:RadGrid>
                 </td>
               </tr>
            </table>
          </asp:Panel>
        </div>

        <div>
          <asp:Panel ID="pnlInfo" runat="server" Visible="False">
                 <div class="header-grid">
                      <asp:Label ID="lblModeName" runat="server" />
                      <asp:Label ID="lblKpiTypeSeq" runat="server" Visible="False" ></asp:Label>
                      <asp:Label ID="lblkpiSeq" runat="server" Visible="False" ></asp:Label>
                      <asp:Label ID="lblBgmYear" runat="server" Visible="False" ></asp:Label>
                      <asp:Label ID="lblBgmStratMapSeq" runat="server" Visible="False" ></asp:Label>
                      <asp:Label ID="lblKpiListTypeSeq" runat="server" Visible="False"></asp:Label>
                      <asp:Label ID="lblKpiTargetSeq" runat="server" Visible="False"></asp:Label>
                 </div>
                      <table width="100%">
                          <tr>
                             <td  align="left" valign="top" bgcolor="#7DA5E0" width="100%" colspan="2" 
                                  style="padding: 5px; color: #FFFFFF; font-weight: bold; font-family: 'Segoe UI'; font-size: 13px;">
                                  <asp:Label ID="lblKpiTargetName" runat="server" Visible="True"></asp:Label>
                             </td>
                          </tr>
                          <tr>
                              <td>ชื่อตัวชี้วัดความสำเร็จ:</td>
                              <td>
                                  <telerik:RadTextBox ID="txtKpiName" runat="server">
                                  </telerik:RadTextBox>
                                  <asp:Label runat="server" ID="lblType" Visible="False"></asp:Label>
                              </td>
                          </tr>
                          <tr>
                              <td>คำอธิบาย:</td>
                              <td>
                                 <telerik:RadTextBox ID="txtDes" runat="server" TextMode="MultiLine" Height="80px" Width="500px">
                                 </telerik:RadTextBox>
                              </td>
                          </tr>
                          <tr>
                              <td>ประเภทตัวชี้วัด:</td>
                              <td>
                                  <telerik:RadComboBox ID="ddlKpiType" runat="server" DataValueField="bgm_kpi_type_seq"
                                    DataTextField="bgm_kpi_type_name"  Filter="Contains"  
                                    EmptyMessage="---กรุณาเลือกประเภทตัวชี้วัด--" HighlightTemplatedItems="true">
                                  </telerik:RadComboBox>
                              </td>
                          </tr>
                          <tr>
                              <td>หน่วยวัด:</td>
                              <td>
                                  <telerik:RadTextBox ID="txtKpiUnit" runat="server" MaxLength="100">
                                  </telerik:RadTextBox>
                              </td>
                          </tr>
                          <tr>
                              <td>น้ำหนัก (ร้อยละ):</td>
                              <td>
                                 <telerik:RadNumericTextBox ID="txtKpiWeight" Runat="server" MaxLength="3" MaxValue="100"
                                    onkeyup="this.value = minmax(this.value, 0, 100)">
                                     <NumberFormat DecimalDigits="0" ZeroPattern="n" />
                                 </telerik:RadNumericTextBox> 
                              </td>
                          </tr>
                     </table>
            </asp:Panel>
       </div> 

       <div>
       <asp:Panel  ID="pnlTarget" runat="server">
          <table style="width: 100%">
            <tr>
                <td align="left" valign="top" bgcolor="#7DA5E0" 
                                  style="padding: 5px; color: #FFFFFF; font-weight: bold; font-family: 'Segoe UI'; font-size: 13px;">
                                  เป้าหมายตัวชี้วัดความสำเร็จ
                 </td>
             </tr>
           </table>
       <telerik:RadComboBox ID="ddlKpiTarget" runat="server" 
               DataTextField="target_name" DataValueField="target_seq" 
               Filter="Contains" HighlightTemplatedItems="true" AutoPostBack="True" 
               OnSelectedIndexChanged="ddlKpiTarget_SelectedIndexChanged">
       </telerik:RadComboBox>
       <asp:Label ID="lblKpiTarget" runat="server"></asp:Label>
      </asp:Panel>
     </div>
       <telerik:RadGrid ID="RadGrid1" runat="server" CellSpacing="0" GridLines="None" AutoGenerateColumns="False" 
            AllowMultiRowEdit="True" AllowMultiRowSelection="True"
            Filter="Contains"  AllowPaging="False" AllowSorting="true"> 
            <MasterTableView>
                <Columns>
                    <telerik:GridBoundColumn UniqueName="target_det_seq" DataField="target_det_seq" Visible="false"></telerik:GridBoundColumn>
                    <telerik:GridBoundColumn UniqueName="kpi_det_seq" DataField="kpi_det_seq" Visible="false"></telerik:GridBoundColumn>
                    <telerik:GridTemplateColumn HeaderText="TargetID" UniqueName="TargetID" 
                        Visible="False" >
                         <ItemTemplate>
                             <telerik:RadTextBox runat="server" id="txtRadTargetSeq" 
                                 Text='<%# Eval("TargetSeq") %>'/> 
                         </ItemTemplate> 
                    </telerik:GridTemplateColumn>
                    <telerik:GridBoundColumn FilterControlAltText="Filter KpiTarget column" 
                        UniqueName="Title" HeaderText="ประเภทเป้าหมาย" DataField="KpiTarget" 
                        ReadOnly="True" >
                    </telerik:GridBoundColumn>
                    <telerik:GridTemplateColumn HeaderText="แผน" UniqueName="Score">
                         <ItemTemplate>
                         <telerik:RadNumericTextBox runat="server" id="txtRadScore" 
                                 Value='<%# String.IsNullOrEmpty(Convert.ToString(Eval("Score"))) ? 0 : Convert.ToDouble(Eval("Score"))%>'/>
                         </ItemTemplate>
                    </telerik:GridTemplateColumn>
                </Columns>
            </MasterTableView>
        </telerik:RadGrid>
    </form>       
</body>
</html>
